using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Data.SqlClient;
using DL;
/// <summary>
/// Summary description for AdvertiedDAL
/// </summary>
namespace DAL 
{
    
    public class AdvertiedDAL  : BaseDAL
    {
    	#region Private Variables

		#endregion
		
 #region Public Constructors
        public AdvertiedDAL()
        {
            //
            // TODO: Add constructor logic here
            //
            
        }
 #endregion       

	
		
#region Public Methods
        public int Insert(AdvertiedDL objAdvertiedDL)
        {
            
            SqlCommand Sqlcomm = new SqlCommand();
            Sqlcomm.CommandType =  CommandType.StoredProcedure;
            Sqlcomm.CommandText =  "Advertied_Insert";
            SqlParameter Sqlparam;

            Sqlparam = new SqlParameter("@Description", SqlDbType.NText);
Sqlparam.Value = objAdvertiedDL.Description;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@Link", SqlDbType.NVarChar);
Sqlparam.Value = objAdvertiedDL.Link;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@ImageUrl", SqlDbType.NVarChar);
Sqlparam.Value = objAdvertiedDL.ImageUrl;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@LanguageId", SqlDbType.Int);
Sqlparam.Value = objAdvertiedDL.LanguageId;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@AdvertiedTypeId", SqlDbType.Int);
Sqlparam.Value = objAdvertiedDL.AdvertiedTypeId;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@Note", SqlDbType.NVarChar);
Sqlparam.Value = objAdvertiedDL.Note;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@Order", SqlDbType.Int);
Sqlparam.Value = objAdvertiedDL.Order;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@ID", SqlDbType.Int);
Sqlparam.Direction = ParameterDirection.ReturnValue;
Sqlcomm.Parameters.Add(Sqlparam);

           
            int result =base.ExecuteNoneQuery(Sqlcomm);
            
            if(!Convert.IsDBNull(Sqlcomm.Parameters["@ID"]))
				result = Convert.ToInt32(Sqlcomm.Parameters["@ID"].Value);

            return result;
        }

        public int Update(AdvertiedDL objAdvertiedDL)
        {
            
            SqlCommand Sqlcomm = new SqlCommand();
            Sqlcomm.CommandType =  CommandType.StoredProcedure;
            Sqlcomm.CommandText =  "Advertied_UpdateByPK";
            SqlParameter Sqlparam;

            Sqlparam = new SqlParameter("@Id", SqlDbType.Int);
Sqlparam.Value = objAdvertiedDL.Id;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@Description", SqlDbType.NText);
Sqlparam.Value = objAdvertiedDL.Description;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@Link", SqlDbType.NVarChar);
Sqlparam.Value = objAdvertiedDL.Link;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@ImageUrl", SqlDbType.NVarChar);
Sqlparam.Value = objAdvertiedDL.ImageUrl;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@LanguageId", SqlDbType.Int);
Sqlparam.Value = objAdvertiedDL.LanguageId;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@AdvertiedTypeId", SqlDbType.Int);
Sqlparam.Value = objAdvertiedDL.AdvertiedTypeId;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@Note", SqlDbType.NVarChar);
Sqlparam.Value = objAdvertiedDL.Note;
Sqlcomm.Parameters.Add(Sqlparam);

Sqlparam = new SqlParameter("@Order", SqlDbType.Int);
Sqlparam.Value = objAdvertiedDL.Order;
Sqlcomm.Parameters.Add(Sqlparam);


            
            Sqlparam = new SqlParameter("@ErrorCode", SqlDbType.Int);
            Sqlparam.Direction = ParameterDirection.ReturnValue;
            Sqlcomm.Parameters.Add(Sqlparam);
            
            int result=base.ExecuteNoneQuery(Sqlcomm);
            
             if (!Convert.IsDBNull(Sqlcomm.Parameters["@ErrorCode"]))
                result = Convert.ToInt32(Sqlcomm.Parameters["@ErrorCode"].Value);
                
            return result;

           
        }

        public int Delete(AdvertiedDL objAdvertiedDL)
        {
            
            SqlCommand Sqlcomm = new SqlCommand();
            Sqlcomm.CommandType =  CommandType.StoredProcedure;
            Sqlcomm.CommandText =  "Advertied_DeleteByPK";
            SqlParameter Sqlparam;


            Sqlparam = new SqlParameter("@Id", SqlDbType.Int);
Sqlparam.Value = objAdvertiedDL.Id;
Sqlcomm.Parameters.Add(Sqlparam);


            
            int result=base.ExecuteNoneQuery(Sqlcomm);
            return result;
        }

         public int DeleteAll()
        {
            
            SqlCommand Sqlcomm = new SqlCommand();
            Sqlcomm.CommandType =  CommandType.StoredProcedure;
            Sqlcomm.CommandText =  "Advertied_DeleteAll";

            int result=base.ExecuteNoneQuery(Sqlcomm);
            return result;
        }

        public AdvertiedDL Select(AdvertiedDL objAdvertiedDL)
        {
            
            SqlCommand Sqlcomm = new SqlCommand();
            Sqlcomm.CommandType =  CommandType.StoredProcedure;
            Sqlcomm.CommandText =  "Advertied_GetByPK";
            SqlParameter Sqlparam;
  

            Sqlparam = new SqlParameter("@Id", SqlDbType.Int);
Sqlparam.Value = objAdvertiedDL.Id;
Sqlcomm.Parameters.Add(Sqlparam);


            
            DataSet ds = base.GetDataSet(Sqlcomm);
            DataRow dr = null;
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                dr = ds.Tables[0].Rows[0];
                if(!Convert.IsDBNull(dr["Id"]))
objAdvertiedDL.Id=Convert.ToInt32(dr["Id"]);
if(!Convert.IsDBNull(dr["Description"]))
objAdvertiedDL.Description=Convert.ToString(dr["Description"]);
if(!Convert.IsDBNull(dr["Link"]))
objAdvertiedDL.Link=Convert.ToString(dr["Link"]);
if(!Convert.IsDBNull(dr["ImageUrl"]))
objAdvertiedDL.ImageUrl=Convert.ToString(dr["ImageUrl"]);
if(!Convert.IsDBNull(dr["LanguageId"]))
objAdvertiedDL.LanguageId=Convert.ToInt32(dr["LanguageId"]);
if(!Convert.IsDBNull(dr["AdvertiedTypeId"]))
objAdvertiedDL.AdvertiedTypeId=Convert.ToInt32(dr["AdvertiedTypeId"]);
if(!Convert.IsDBNull(dr["Note"]))
objAdvertiedDL.Note=Convert.ToString(dr["Note"]);
if(!Convert.IsDBNull(dr["Order"]))
objAdvertiedDL.Order=Convert.ToInt32(dr["Order"]);

            }
             return objAdvertiedDL;
        }

        public ArrayList SelectAll1( )
        {
			
            SqlCommand Sqlcomm = new SqlCommand();
            Sqlcomm.CommandType =  CommandType.StoredProcedure;
            Sqlcomm.CommandText =  "Advertied_GetAll";
            
            DataSet ds = base.GetDataSet(Sqlcomm);
            DataTable dt = null;
            ArrayList arrAdvertiedDL = new ArrayList();
            if (ds != null && ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
                foreach(DataRow dr in dt.Rows)
{
AdvertiedDL objAdvertiedDL= new AdvertiedDL();
if(!Convert.IsDBNull(dr["Id"]))
objAdvertiedDL.Id=Convert.ToInt32(dr["Id"]);
if(!Convert.IsDBNull(dr["Description"]))
objAdvertiedDL.Description=Convert.ToString(dr["Description"]);
if(!Convert.IsDBNull(dr["Link"]))
objAdvertiedDL.Link=Convert.ToString(dr["Link"]);
if(!Convert.IsDBNull(dr["ImageUrl"]))
objAdvertiedDL.ImageUrl=Convert.ToString(dr["ImageUrl"]);
if(!Convert.IsDBNull(dr["LanguageId"]))
objAdvertiedDL.LanguageId=Convert.ToInt32(dr["LanguageId"]);
if(!Convert.IsDBNull(dr["AdvertiedTypeId"]))
objAdvertiedDL.AdvertiedTypeId=Convert.ToInt32(dr["AdvertiedTypeId"]);
if(!Convert.IsDBNull(dr["Note"]))
objAdvertiedDL.Note=Convert.ToString(dr["Note"]);
if(!Convert.IsDBNull(dr["Order"]))
objAdvertiedDL.Order=Convert.ToInt32(dr["Order"]);
arrAdvertiedDL.Add(objAdvertiedDL);
}
            }
               return arrAdvertiedDL;
        }
        
        public DataTable SelectAll( )
        {
			
            SqlCommand Sqlcomm = new SqlCommand();
            Sqlcomm.CommandType =  CommandType.StoredProcedure;
            Sqlcomm.CommandText =  "Advertied_GetAll";
            
            DataSet ds = base.GetDataSet(Sqlcomm);
            DataTable dt = null;
          
            if (ds != null && ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
                
            }
               return dt;
        }

     
#endregion          
    
    }

}
